package io.ooad.banking.dd.domain;

import javax.persistence.*;
import java.util.Date;

/**
 * 转出
 * Created by yyang on 16/9/16.
 */
@Entity
@DiscriminatorValue("T")
public class TransferOutTransaction extends AccountTransaction {

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "peer_tx_id")
    private TransferInTransaction inTx;

    @ManyToOne
    @JoinColumn(name = "peer_account_id")
    private BankAccount creditAccount;

    TransferOutTransaction() {
    }

    public TransferOutTransaction(BankAccount account, TransferInTransaction inTx, Money amount, Date date) {
        super(account, amount, date);
        this.inTx = inTx;
        this.creditAccount = inTx.getAccount();
    }

    public TransferInTransaction getInTx() {
        return inTx;
    }

    public BankAccount getCreditAccount() {
        return creditAccount;
    }
}
